<html  lang="en" xmlns:th="http://www.thymeleaf.org">
<script src="http://cdn.bootcss.com/sockjs-client/1.1.1/sockjs.min.js"></script>
<script src="http://cdn.bootcss.com/stomp.js/2.3.3/stomp.js"></script>
<script type="text/javascript">
    var url = "http://192.168.0.108:8088/stompwebsocket";
    var socket = new SockJS(url);
    var stompClient = Stomp.over(socket);
    stompClient.connect({}, function(frame) {
        if (pointId != null){
            stompClient.subscribe('/topic/monitoring/'+pointId, function(txt) {
                document.getElementById('message').innerHTML += txt+'<br/>';
            });
        } else{
            stompClient.subscribe('/topic/monitoring/1', function(txt) {
                document.getElementById('message').innerHTML += txt+'<br/>';
            });
        }

    });
    var setTimeName;
    var i = 0;
    var setTimeDemo = function () {
        send("-1")
        alert("执行了 "+ ++i +" 次");
        setTimeName = setTimeout(setTimeDemo,2000);
    }
    function send(pointId) {
        var pointId = document.getElementById("text").value;
        stompClient.send("/app/ack", {}, pointId);
    }
</script>
<meta http-equiv="Content-Type" content="text/html" charset="UTF-8"/>
<title>首页大屏幕推送</title>
<div id="container">
    <div id="message">

    </div>
    <div>
        <input id="text" type="text" placeholder="输入内容..."/>
        <button onclick="send()">发送消息</button>
    </div>
    <div id="message2">

    </div>
</div>
</html>
